#ifndef HTTPRESPONSEHEADER_H
#define HTTPRESPONSEHEADER_H

#include <string>
#include <map>
#include "Log.h"

class HttpResponseHeader
{
public:
	HttpResponseHeader()
		:m_tempBuffer(new std::string()),m_Version(),m_statusCode(0),m_reason(),m_headers(),m_bodyIndex(0)
	{
	}
	
	~HttpResponseHeader();

	bool IsValid();

	void AppendData(char*,char*);

	std::string& Version()
	{
		return m_Version;
	}

	int StatusCode()
	{
		return m_statusCode;
	}

	std::string& Reason()
	{
		return m_reason;
	}

	std::map<std::string,std::string>& Headers()
	{
		return m_headers;
	}

	std::string& TempBuffer()
	{
		return *m_tempBuffer;
	}

	std::string::size_type& BodyIndex()
	{
		return m_bodyIndex;
	}

	bool SetRequestRangeWithCheck(long long &min,long long &max);

	void Reset();

	void FreeTempBuffer();

private:
	static log4cplus::Logger log;

	void ParseHeaderAndPartialBody();

	std::string *m_tempBuffer;

	std::string m_Version;

	int m_statusCode;

	std::string m_reason;

	std::map<std::string,std::string> m_headers;

	std::string::size_type m_bodyIndex;
};

#endif